//
//  QSBannerViewController.swift
//  CardBanner
//
//  Created by Song on 2019/2/23.
//  Copyright © 2019 Song. All rights reserved.
//

import UIKit

class QSBannerViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        view.backgroundColor = .white
        title = "Banner"
        
        view.addSubview(imagesCycleView)
        imagesCycleView.frame = CGRect.init(x: 0, y: 200.0, width: kScreenWidth, height: 200.0)
        imagesCycleView.dataArray = ["https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1550900621459&di=a284dcb615570c39251c16d82c10321c&imgtype=0&src=http%3A%2F%2Fwww.pptbz.com%2Fpptpic%2FUploadFiles_6909%2F201306%2F2013062320262198.jpg",
                                     "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1550900653396&di=16da218d8d8b0eb1d1fd73a5dc2637bb&imgtype=0&src=http%3A%2F%2Fwww.pptok.com%2Fwp-content%2Fuploads%2F2012%2F08%2Fxunguang-4.jpg",
                                     "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1550900670112&di=2a4c19d6a1b8cab6566ef29725f6303d&imgtype=0&src=http%3A%2F%2Fimg.bimg.126.net%2Fphoto%2FZZ5EGyuUCp9hBPk6_s4Ehg%3D%3D%2F5727171351132208489.jpg"]
        imagesCycleView.selectedBlock = { (index) in
            print(index)
        }
        
        view.addSubview(textCycleView)
        textCycleView.frame = CGRect.init(x: 0, y: 450.0, width: kScreenWidth, height: 50.0)
        textCycleView.dataArray = ["1111111111",
                                   "2222222222",
                                   "3333333"]
        textCycleView.selectedBlock = { (index) in
            print(index)
        }
    }
    
    private lazy var imagesCycleView: QSImageBannerView = {
        let model = QSBaseBannerModel.init()
        model.timeInterval = 3.0
        model.isAutoRun = true
        
        model.isNeedPageControl = true
        model.pageControlBottomMargin = 15.0
        model.pageControlHeight = 30.0
        model.pointWidth = 6.0
        model.pointHeight = 6.0
        model.pointSpace = 8.0
        model.otherPointColor = .blue
        model.currentPointColor = .red
        model.currentPointImage = nil
        model.otherPointImage = nil
        model.pageControlLocation = .middle
        model.pointScale = 1.0
        model.isEllipse = false
        
        model.itemSize = CGSize.init(width: kScreenWidth - 45.0, height: 200.0)
        model.itemWidthMargin = kAdaptedWidth(10.0)
        model.itemHeigtMargin = kAdaptedWidth(10.0)
        model.isCardStytle = false
        model.visibleCount = 3
        model.collectionViewBgColor = .gray
        
        let imagesCycleView = QSImageBannerView.init(frame: .zero)
        imagesCycleView.stytleModel = model
        return imagesCycleView
    }()
    
    private lazy var textCycleView: QSTextBannerView = {
        let model = QSBaseBannerModel.init()
        model.timeInterval = 3.0
        model.isAutoRun = true
        
        model.isNeedPageControl = false
        
        model.itemSize = CGSize.init(width: kScreenWidth, height: 50.0)
        
        model.isCardStytle = false
        model.visibleCount = 3
        model.collectionViewBgColor = .gray
        model.scrollDirection = .vertical
        
        let textCycleView = QSTextBannerView.init(frame: .zero)
        textCycleView.stytleModel = model
        return textCycleView
    }()
}
